/**
* All Rights Reserved , Copyright (C) 2020 , 青岛鼎信通讯股份有限公司
*
* EhrCollegeService
* 学校档案
*
* 修改纪录
* 2020-09-03 版本：1.0 wangxinhua 创建。
* @version 版本：1.0
* @author 作者：wangxinhua
* 创建日期：2020-09-03
*/
package com.topscomm.base.service.impl;

import com.topscomm.base.pojo.BaseCollegeEntity;
import com.topscomm.base.service.IBaseCollegeService;
import com.topscomm.base.service.impl.auto.BaseCollegeServiceAuto;
import com.topscomm.basic.BasicEntity;
import com.topscomm.basic.util.PrimaryKeyUtil;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

@Service(value = "ehrCollegeService")
@Scope(value = "singleton")
public class BaseCollegeService extends BaseCollegeServiceAuto implements IBaseCollegeService {


	@Override
	protected void beforeInsert(BasicEntity entity){
		super.beforeInsert(entity);
		if (entity.getId() <= 0) {// 赋值Id和单号
			long[] arrayId = PrimaryKeyUtil.GeneIDs(entity.getTableName(), 1);
			entity.setId(arrayId[0]);
			String docNo = String.valueOf(arrayId[0]);
			docNo = docNo.substring(0, 6) + docNo.substring(9);
			entity.setValue(BaseCollegeEntity.FieldDocno, docNo);
		}
	}
}
